﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
namespace GSLMS.Entity
{
	/// <summary>
	/// 2.2.4    境内公司信息
	/// </summary>
	[DataContract(IsReference = true)]
	public partial class TB_DA_CHURCORP: IObjectWithChangeTracker, INotifyPropertyChanged
	{
		public TB_DA_CHURCORP()
		{}
		#region Model
		private long _id;
		private string _corpname;
		private string _legal;
		private decimal _regcapital;
		private Nullable<DateTime> _founddate;
		private int _belongto;
		private Nullable<DateTime> _buydate;
		private Nullable<DateTime> _saledate;
		private string _regaddr;
		private string _provefile;
		private string _bussscope;
		private string _remark;
		/// <summary>
		/// 记录ID
		/// </summary>
		[DataMember]
		public long ID
		{
			get{return _id;}
			set{
				if ( _id!= value)
				{
					if (ChangeTracker.ChangeTrackingEnabled && ChangeTracker.State != ObjectState.Added)
					{
						throw new InvalidOperationException("属性“ID”是对象键的一部分，不可更改。仅当未跟踪对象或对象处于“已添加”状态时，才能对键属性进行更改。");
					}
					 _id = value;
					OnPropertyChanged("ID");
				}
			}
		}
		/// <summary>
		/// 公司名称
		/// </summary>
		[DataMember]
		public string CORPNAME
		{
			get{return _corpname;}
			set{
				if ( _corpname!= value)
				{
					 _corpname = value;
					OnPropertyChanged("CORPNAME");
				}
			}
		}
		/// <summary>
		/// 法人代表
		/// </summary>
		[DataMember]
		public string LEGAL
		{
			get{return _legal;}
			set{
				if ( _legal!= value)
				{
					 _legal = value;
					OnPropertyChanged("LEGAL");
				}
			}
		}
		/// <summary>
		/// 注册资金以万元为单位
		/// </summary>
		[DataMember]
		public decimal REGCAPITAL
		{
			get{return _regcapital;}
			set{
				if ( _regcapital!= value)
				{
					 _regcapital = value;
					OnPropertyChanged("REGCAPITAL");
				}
			}
		}
		/// <summary>
		/// 成立时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> FOUNDDATE
		{
			get{return _founddate;}
			set{
				if ( _founddate!= value)
				{
					 _founddate = value;
					OnPropertyChanged("FOUNDDATE");
				}
			}
		}
		/// <summary>
		/// 归属1自由、2收购、3转让、4出售
		/// </summary>
		[DataMember]
		public int BELONGTO
		{
			get{return _belongto;}
			set{
				if ( _belongto!= value)
				{
					 _belongto = value;
					OnPropertyChanged("BELONGTO");
				}
			}
		}
		/// <summary>
		/// 收购日期如果‘归属’项选择‘收购’时，此数据项必填
		/// </summary>
		[DataMember]
		public Nullable<DateTime> BUYDATE
		{
			get{return _buydate;}
			set{
				if ( _buydate!= value)
				{
					 _buydate = value;
					OnPropertyChanged("BUYDATE");
				}
			}
		}
		/// <summary>
		/// 转让/出售日期，如果‘归属’项选择‘转让、出售’时，此数据项必填
		/// </summary>
		[DataMember]
		public Nullable<DateTime> SALEDATE
		{
			get{return _saledate;}
			set{
				if ( _saledate!= value)
				{
					 _saledate = value;
					OnPropertyChanged("SALEDATE");
				}
			}
		}
		/// <summary>
		/// 注册地址
		/// </summary>
		[DataMember]
		public string REGADDR
		{
			get{return _regaddr;}
			set{
				if ( _regaddr!= value)
				{
					 _regaddr = value;
					OnPropertyChanged("REGADDR");
				}
			}
		}
		/// <summary>
		/// 证明文件
		/// </summary>
		[DataMember]
		public string PROVEFILE
		{
			get{return _provefile;}
			set{
				if ( _provefile!= value)
				{
					 _provefile = value;
					OnPropertyChanged("PROVEFILE");
				}
			}
		}
		/// <summary>
		/// 经营范围
		/// </summary>
		[DataMember]
		public string BUSSSCOPE
		{
			get{return _bussscope;}
			set{
				if ( _bussscope!= value)
				{
					 _bussscope = value;
					OnPropertyChanged("BUSSSCOPE");
				}
			}
		}
		/// <summary>
		/// 备注
		/// </summary>
		[DataMember]
		public string REMARK
		{
			get{return _remark;}
			set{
				if ( _remark!= value)
				{
					 _remark = value;
					OnPropertyChanged("REMARK");
				}
			}
		}
		#endregion Model

	#region ChangeTracking
	   
	protected virtual void OnPropertyChanged(String propertyName)
	{
	    if (ChangeTracker.State != ObjectState.Added && ChangeTracker.State != ObjectState.Deleted)
	    {
	        ChangeTracker.State = ObjectState.Modified;
	    }
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	protected virtual void OnNavigationPropertyChanged(String propertyName)
	{
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged{ add { _propertyChanged += value; } remove { _propertyChanged -= value; } }
	private event PropertyChangedEventHandler _propertyChanged;
	private ObjectChangeTracker _changeTracker;
	   
	[DataMember]
	public ObjectChangeTracker ChangeTracker
	{
	    get
	    {
	        if (_changeTracker == null)
	        {
	            _changeTracker = new ObjectChangeTracker();
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	        return _changeTracker;
	    }
	    set
	    {
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging -= HandleObjectStateChanging;
	        }
	        _changeTracker = value;
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	    }
	}
	   
	private void HandleObjectStateChanging(object sender, ObjectStateChangingEventArgs e)
	{
	    if (e.NewState == ObjectState.Deleted)
	    {
	        ClearNavigationProperties();
	    }
	}
	   
	protected bool IsDeserializing { get; private set; }
	   
	[OnDeserializing]
	public void OnDeserializingMethod(StreamingContext context)
	{
	    IsDeserializing = true;
	}
	   
	[OnDeserialized]
	public void OnDeserializedMethod(StreamingContext context)
	{
	    IsDeserializing = false;
	    ChangeTracker.ChangeTrackingEnabled = true;
	}
	   
	protected virtual void ClearNavigationProperties()
	{
	}
	
	#endregion

	}
}

